package com.sevenGroup.pawnshop.Utils;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result<T> {
    private Integer state;
    private String message;
    private T date;
    public static Result success(Object o){
        Result result = new Result();
        result.setDate(o);
        result.setState(200);
        result.setMessage("成功");
        return result;
    }
    public static Result fail(Object o){
        Result result = new Result();
        result.setDate(o);
        result.setState(500);
        result.setMessage("失败");
        return result;
    }

    public Result setState(Integer state) {
        this.state = state;
        return this;
    }

    public Result setMessage(String message) {
        this.message = message;
        return this;
    }

    public Result setDate(T date) {
        this.date = date;
        return this;
    }
}
